package control
{
	import flash.display.Sprite;
	
	import view.UIlayer.CardView;
	
	import vo.*;
	import vo.GameMode;
	
	//	1.生成牌；2.洗牌；3.发牌
	
	public class CardMachine extends Sprite
	{
		
		private var gm:GameMode = GameMode.getInstance();
		
		
		public function CardMachine()
		{
			init();
		}
		
		private function init():void{
			createCardList();
			shuffle();
		}
		//		生成牌
		
		public function createCardList():void{	
			gm.cardList = new Array();
			for (var j:int = 1; j <= 13 ; j++){					
				gm.cardList.push( j );
			}	
		}
		
		//洗牌
		
		public function shuffle ():void{
			
			for(var i:int = 0 ; i < gm.cardList.length ; i++){
				
				var tmpCardA : int = ( gm.cardList.length) * Math.random();
				var tmpCardB : int = ( gm.cardList.length) * Math.random();
				
				var tempCard:int = gm.cardList[tmpCardA];
				gm.cardList[tmpCardA] = gm.cardList[tmpCardB];
				gm.cardList[tmpCardB] = tempCard;
			}
			
			trace("洗好的牌" + gm.cardList);
		}
		
		//发牌		
		public function hitCard ():int{
			//暂存一下牌
			return gm.cardList.pop();			
		}
	}
}